import hilog from '@ohos.hilog';
import UIAbility from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'
import JsApplication  from '../native/QtCore/JsApplication'
import JsDataStore from '../native/QtCore/JsDataStore'
import JSLogger from '../native/QtCore/JsLogger'

export default class EntryAbility extends UIAbility {

    onCreate(want, launchParam) {
        JsDataStore.setContext(this.context);
        JsDataStore.setElementName({
            bundleName: want.bundleName,
            abilityName: want.abilityName,
            moduleName: want.moduleName
        });
    }

    onDestroy() {
        JSLogger.info('%{public}s', 'Ability onDestroy');
        JsApplication.quit();
    }

    onWindowStageCreate(windowStage: Window.WindowStage) {
        // Main window is created, set main page for this ability
        JSLogger.info('%{public}s', '11Ability onWindowStageCreate');
        JsApplication.run(windowStage);
    }

    onWindowStageDestroy() {
        // Main window is destroyed, release UI related resources
        JSLogger.info('%{public}s', 'Ability onWindowStageDestroy');
    }

    onForeground() {
        // Ability has brought to foreground
        JSLogger.info('%{public}s', 'Ability onForeground');
    }

    onBackground() {
        // Ability has back to background
        JSLogger.info('%{public}s', 'Ability onBackground');
    }
};
